package com.hlm.temperature_regulate.mapper;

import com.hlm.temperature_regulate.dao.WeatherInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
/**
 * 写mapper时 先在mysql里写测试 在放到这里
 */
public interface WeatherMapper {
    @Insert("insert into weather_d(day_temperature,night_temperature,date) values(#{dayTemperature},#{nightTemperature},#{date})")
    Integer insertWeather(WeatherInfo weatherInfo);

    @Select("select wc.day_temperature+0.0,ri.in_temp+0.0,ri.water_temp+0.0,ri.terminal_id,ri.date\n" +
            "FROM weather_c wc\n" +
            "JOIN regulate_info_qd ri\n" +
            "ON wc.date=DATE_FORMAT(ri.date,'%Y%m%d')\n" +
            "WHERE wc.date BETWEEN '2020-01-01' AND '2020-05-01'\n" +
            "AND DATE_FORMAT(ri.date,'%H:%i')='14:00'")
    Integer getTempOut();
}
